package com.example.sls.controller;

import com.example.sls.utils.QRCodeUtil;
import com.google.zxing.WriterException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.io.OutputStream;

/**
 * 编者：蓝江富
 * 时间：2024/6/14 15:46
 */
@RequestMapping("test")
@RestController
public class CrodController {

  @RequestMapping("codeone")
  public void TwoCode(HttpServletResponse response, HttpServletRequest request){
    String requestUrl="https://u.wechat.com/MJnt4pDcLNhUBWCpNnFUISk?s=2";
    try {
      OutputStream os=response.getOutputStream();
      QRCodeUtil.encode(requestUrl,"D:\\Pictures\\201.png",os);
    } catch (IOException e) {
      throw new RuntimeException(e);
    } catch (WriterException e) {
      throw new RuntimeException(e);
    }
  }
}
